< previous page page_562 next page >

Page 562
When youre loading the list box, you simply need to separate each column in the list box with a tab (vbTab) character. Therefore, the routine to load the states into the list box looks like this:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub StateLoad()
   With lstStates
      .AddItem "CA" & vbTab & "California"
      .AddItem "AZ" & vbTab & "Arizona"
      .AddItem "OR" & vbTab & "Oregon"
      .AddItem "WA" & vbTab & "Washington"
      .AddItem "NV" & vbTab & "Nevada"
   End With
End Sub
Using the vbTab constant tells the list box that the text will be placed after the first tab stop. The vbTab constant evaluates to Chr$(9).
When you select an item from a list box that contains tabs, youll retrieve the data with the tab contained in the text field. This means that if you want to get the data in a particular column, youll need to parse out the tabs to get to the particular data you want. Figure 28.4 shows what the data might look like when its returned from the Text property of the list box.
8160-0562a.gif
Figure 28.4
Data returned from a tabbed list box.
Multiple Tab Stops
Sometimes you may want to have multiple columns of data, similar to a grid control. You can create multiple tab stops in a list box using the same SendMessage() function. In Figure 28.5, three tab stops are created in the list box.

 
< previous page page_562 next page >

If you like this book, buy it!